<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Demo</title>
</head>
<body>
	
	<script>
	var email=prompt("请输入登录邮箱");
	function getName(name){
		var pos=email.indexOf("@");
		return name.substr(0,pos)
	}
	function getName1(name1){
		var pos1=email.lastIndexOf("@");
		return name1.substr(pos1+1);
	}
	document.write("邮箱的用户名是:" + getName(email)+"<br>" + "登录的邮箱域名是:" +getName1(email))
	</script>
</body>
</html>
